package com.jbm.le;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.Window;

import com.jbm.enterapplication.R;


public class MainActivity extends Activity {
	@SuppressLint("NewApi")
	@Override
	protected void onCreate(Bundle savedInstanceState) 	{
		super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_sub);
		Intent intent = getIntent();
			if(intent.getStringExtra("address")!=null){
//
		Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
	    	gattServiceIntent.putExtra("address", intent.getStringExtra("address"));
	    	gattServiceIntent.putExtra("cmd", intent.getStringExtra("cmd"));
	    	gattServiceIntent.putExtra("timeout", intent.getIntExtra("timeout",10));
	    	gattServiceIntent.putExtra("ifhex", intent.getBooleanExtra("ifhex",false));
				gattServiceIntent.putExtra("name",intent.getStringExtra("name"));
				gattServiceIntent.putExtra("log_id",intent.getIntExtra("log_id",0));
				gattServiceIntent.putExtra("egk_id",intent.getIntExtra("egk_id",0));
				gattServiceIntent.putExtra("ega_id",intent.getIntExtra("ega_id",0));
				gattServiceIntent.putExtra("open_count",intent.getIntExtra("open_count",0));
	        bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);

			} else{
//

//
//
			}
	         /*
	    	gattServiceIntent.putExtra("address", "00:08:07:03:07:E3");
	    	gattServiceIntent.putExtra("cmd","AABBCCEE");
	    	gattServiceIntent.putExtra("timeout", intent.getIntExtra("timeout",10)); 
	    	gattServiceIntent.putExtra("ifhex", intent.getBooleanExtra("ifhex",false)); 
	        bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE); 
	         *///this.moveTaskToBack(true);
	        
        
	}
	
	private final ServiceConnection mServiceConnection = new ServiceConnection() 
	{
        @Override
        public void onServiceConnected(ComponentName componentName, IBinder service) {
			Log.v("main","接收地址信息"+"路过");

		}

        @Override
        public void onServiceDisconnected(ComponentName componentName) {
			Log.v("main","接收地址信息"+"路过---00");
        }
    };

}
